<?php

declare(strict_types=1);

namespace Modules\Cms\Http\Controllers;

use Carbon\Carbon;
use Catch\Base\CatchController as Controller;
use Illuminate\Http\Request;
use Modules\Cms\Models\Source;


class SourcesController extends Controller
{
    public function __construct(
        protected readonly Source $model
    ) {
    }

    /**
     * @param  Request  $request
     */
    public function index(): mixed
    {
        return $this->model->getList();
    }

    public function store(Request $request)
    {

        $params = $request->all();
        $params['date'] = date("Y-m-d");
        return $this->model->storeBy($params);
    }

    public function show($id)
    {
        return $this->model->firstBy($id);
    }

    public function update($id, Request $request)
    {
        return $this->model->updateBy($id, $request->all());
    }

    public function destroy($id)
    {
        return $this->model->deletesBy($id);
    }
}
